﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SenderVerify.aspx.cs" Inherits="OnlineBusinesses.Areas.CustomerAdmin.SenderVerify" MasterPageFile="~/Areas/CustomerAdmin/Customer.Master"%>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="ContentCustomerAdmin">
    <div style="width: 100%; padding: 10px;">
        <!--start content 01-->
        <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="border: 1px solid #eee; padding: 0px; margin-bottom: 10px;" id="divList">
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="padding: 10px 20px; background: #eee; color: #333; font-size: 18px; font-weight: bold; position: relative;">
                Danh sách hoàn tất verify với hệ thống FAmails.com
            </div>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 10px;">
                <asp:Panel Visible="false" ID="pnError" runat="server">
                    <div class="error-box round">
                        <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
                    </div>
                </asp:Panel>
                <asp:Panel Visible="false" ID="pnSuccess" runat="server">
                    <div class="confirmation-box round">
                        <asp:Label ID="lblSuccess" runat="server" Text=""></asp:Label>
                    </div>
                </asp:Panel>
            </div>
            <div class="col-md-4 col-xs-12 col-sm-6 col-lg-4" style="height: auto; padding: 10px;">
                <fieldset>
                    <p>
                        <label for="simple-input" style="font-weight: bolder; text-transform: none">
                            Email Verify</label>
                        <asp:TextBox ID="txtEmailVerify" CssClass="input_add"
                            runat="server"></asp:TextBox>
                        <em style="color: #333;">Email xác thực.</em>
                    </p>
                </fieldset>
            </div>
            <div class="col-md-4 col-xs-12 col-sm-6 col-lg-4" style="height: auto; padding: 10px;">
                <fieldset>
                    <p>
                        <label for="simple-input" style="font-weight: bolder; text-transform: none">
                            Tên cấu hình</label>
                        <asp:TextBox ID="txtNameConfig" CssClass="input_add"
                            runat="server"></asp:TextBox>
                        <em style="color: #333;">Tên hiển thị khi gửi tin.</em>
                    </p>
                </fieldset>
            </div>
            <div class="col-md-4 col-xs-12 col-sm-6 col-lg-4" style="height: auto; padding: 10px; padding-top: 35px;">
                <fieldset>
                    <button id="Button1" runat="server" class="btn col-md-6 col-xs-6 col-sm-6 col-lg-6" style="border: 1px solid #fff; float: left; background: #337BEA; color: #fff; text-align: center; padding: 6px 10px; border-radius: 0px;"
                        onserverclick="btnVerify_Click">
                        <i class="fa fa-check"></i>Xác nhận email
                    </button>
                    <div id="btnSearch" style="border: 1px solid #fff; float: left; background: #337BEA; color: #fff; text-align: center; padding: 6px 14px; border-radius: 0px;" class="btn col-md-6 col-xs-6 col-sm-6 col-lg-6">
                        <span style="margin-right: 10px;" class="fa fa-desktop"></span>Lọc dữ liệu
                    </div>
                    <asp:Label ID="lbuser" runat="server" Visible="False"></asp:Label>
                </fieldset>
            </div>
            <div class="col-md-12 col-xs-12 col-sm-6 col-lg-12" style="height: auto; padding: 10px;" runat="server" id="pnWarning">
                <div style="border-radius: 0px; padding: 10px; font-size: 14px; border: 1px solid #f55; background: #fee; color: #f55; line-height: 20px;">
                    Lưu ý: đối với email chưa được cấu hình DNS với FAmails. Quý khách chỉ được gửi tối đa 300 emails/ngày
                </div>
            </div>
            <style>
                #contentjqxgrid {
                    width: 100% !important;
                }

                #pagerjqxgrid {
                    width: 100% !important;
                }

                #columntablejqxgrid {
                    width: 100% !important;
                }

                .jqx-grid-header {
                    width: 100% !important;
                }
            </style>
            <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12" style="height: auto; padding: 0px;">
                <div id='jqxWidget' style="width: 100% !important; font-size: 13px; font-family: Verdana; float: left;">
                    <div id="jqxgrid" style="width: 100% !important">
                    </div>

                    <div id="popupWindow">
                        <div>
                            Xóa cấu hình
                        </div>
                        <div style="overflow: hidden;">
                            <p>
                                Bạn có chắc là muốn xóa cấu hình này không?
                            </p>
                            <button id="del">
                                Yes</button>
                            <button id="cancel">
                                No</button>
                        </div>
                    </div>
                </div>
                <asp:HiddenField runat="server" ID="hdfUser" />
                <!----------------->
                <script type="text/javascript">
                    jQuery(function ($) {
                        //alert(id);
                        var cellsrenderer = function (row, column, value) {
                            var domain = $("#jqxgrid").jqxGrid('getcellvalue', row, "Email");
                            //alert(name);
                            return '<a  target="_blank" style="margin-top: 2px" href="DomainDetail.aspx?dm=' + domain.split('@')[1] + '">Lấy cấu hình DNS</a>';
                        };
                        $("#btnSearch").click(function () {
                            $("#jqxgrid").jqxGrid('showloadelement');
                            $.ajax({
                                type: "POST",
                                url: "SenderVerify.aspx/search",
                                //data: postValue,
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (data) {
                                    var source =
                            {
                                datatype: "json",
                                datafields: [
                                    { name: 'Id', type: 'int' },
                                    { name: 'Name', type: 'string' },
                                      { name: 'Email', type: 'string' },
                                      { name: 'dnsVerified', type: 'string' },
                                      { name: 'status', type: 'string' }
                                ],
                                id: 'Id',
                                localdata: data,
                                pager: function (pagenum, pagesize, oldpagenum) {
                                }
                            };
                                    var dataAdapter = new $.jqx.dataAdapter(source);
                                    $("#jqxgrid").jqxGrid(
                                    {
                                        width: $('#jqxWidget').width(),
                                        source: dataAdapter,
                                        selectionmode: 'multiplerowsextended',
                                        sortable: true,
                                        pageable: true,
                                        autoheight: true,
                                        columnsresize: true,
                                        columns: [
                                          { text: 'Tên cấu hình', datafield: 'Name' },
                                          { text: 'Email gửi', datafield: 'Email' },
                                          { text: 'Trạng thái đăng ký DNS', datafield: 'dnsVerified' },
                                          { text: 'Lấy cấu hình DNS',  cellsrenderer: cellsrenderer },
                                          { text: 'Trạng thái cấu hình', datafield: 'status' },
                                           {
                                               text: 'Xóa', datafield: 'Id', columntype: 'button', cellsrenderer: function () {
                                                   return "Xóa";
                                               }, buttonclick: function (row) {
                                                   // open the popup window when the user clicks a button.
                                                   id = $("#jqxgrid").jqxGrid('getrowid', row);
                                                   var offset = $("#jqxgrid").offset();
                                                   $("#popupWindow").jqxWindow({ position: { x: parseInt(offset.left) + ($('#divList').width() / 2 - 150), y: parseInt(offset.top) + 60 } });
                                                   // show the popup window.
                                                   $("#popupWindow").jqxWindow('show');
                                               }
                                           }
                                        ]
                                    });

                                }
                            });
                        });
                        $("#popupWindow").jqxWindow({ width: 250, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.01 });
                        $("#del").jqxButton({ theme: theme });
                        $("#cancel").jqxButton({ theme: theme });
                        $("#del").click(function () {
                            $.ajax({
                                type: "POST",
                                url: "SenderVerify.aspx/Delete",
                                data: "{id:" + id + "}",
                                contentType: "application/json; charset=utf-8",
                                dataType: "json",
                                success: function (data) {
                                    $('#jqxgrid').jqxGrid('deleterow', id);
                                    $("#popupWindow").jqxWindow('hide');
                                    $('#btnSearch').trigger('click');
                                }
                            });
                        });
                        $("#cancel").click(function () {
                            $("#popupWindow").jqxWindow('hide');
                        });
                        $('#btnSearch').trigger('click');
                    });

                </script>
            </div>
        </div>
    </div>
</asp:Content>

